package com.storage.web.controller.system;

import com.storage.common.annotation.Log;
import com.storage.common.core.controller.BaseController;
import com.storage.common.core.domain.AjaxResult;
import com.storage.common.core.domain.ServiceResponse;
import com.storage.common.core.page.TableDataInfo;
import com.storage.common.enums.BusinessType;
import com.storage.framework.web.OperationContext;
import com.storage.framework.web.enums.RequestOperation;
import com.storage.system.domain.StorageAccountRecord;
import com.storage.system.service.IStorageAccountRecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 付款记录 信息操作处理
 *
 * @author ruoyi
 * @date 2019-09-20
 */
@RestController
public class StorageAccountRecordController extends BaseController {

    @Autowired
    private IStorageAccountRecordService storageAccountRecordService;

    /**
     * 查询付款记录列表
     */
    @ApiOperation(value = "查询付款记录列表", notes = "查询付款记录列表")
    @GetMapping("/system/account/list")
    @ResponseBody
    public TableDataInfo list(StorageAccountRecord storageAccountRecord, Integer pageNum, Integer pageSize) {
        ServiceResponse<TableDataInfo> response = storageAccountRecordService.selectStorageAccountRecordList(storageAccountRecord, pageNum, pageSize);
        return response.getData();
    }

    /**
     * 新增保存付款记录
     */
    @ApiOperation(value = "新增保存付款记录", notes = "新增保存付款记录")
    @Log(title = "付款记录", businessType = BusinessType.INSERT)
    @PostMapping("/system/account/add")
    @ResponseBody
    public AjaxResult addSave(@RequestOperation OperationContext context,
                              @RequestBody StorageAccountRecord record) {
        ServiceResponse<StorageAccountRecord> response = storageAccountRecordService.insertStorageAccountRecord(context.getStorageUser(), record);
        return AjaxResult.success(response.getData());
    }

}
